package com.guomao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/cookiedemo")
public class CookieServletDemoA extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //1 创建cookie
//        Cookie cookie = new Cookie("cookiedemo", "hellocookie");
        Cookie cookie = new Cookie("cookiedemo", "abcde");

        //2 设置声明周期
//        cookie.setMaxAge(60 * 60);


        StringBuilder sb = new StringBuilder();

        sb.append("<html>").append(1).append(true);
//        删除cookie
        cookie.setMaxAge(0);
        resp.addCookie(cookie);

    }
}
